<script setup>
import { ref, onMounted } from "vue";
import NaiveUITheme from "@/config/json/NaiveUITheme.json";
import { storeToRefs } from "pinia";
import { mainData } from "@/stores/index";
import router from "@/router";

// 主题配置项
let theme = ref(NaiveUITheme);
// 创建状态库
let piniaData = mainData();
let { ifUserAuthority } = storeToRefs(piniaData);

/**
 * 权限认证方法
 */
function userAuthorityIf() {
  if (!mainData().ifUserAuthority) {
    router.push("/login");
  } else {
    // console.log("这是入口");
    router.push("/work");
  }
}

onMounted(() => {
  userAuthorityIf();
});
</script>

<template>
  <n-loading-bar-provider style="height: 100%">
    <n-config-provider style="height: 100%" :theme-overrides="theme">
      <n-notification-provider>
        <n-message-provider>
          <router-view></router-view>
        </n-message-provider>
      </n-notification-provider>
    </n-config-provider>
  </n-loading-bar-provider>
</template>

<style scoped></style>
